<template>
  <section class="around-the-mall">
    <!-- 周边商城 -->
    <h1>周边商城</h1>
    <!-- 横向排列商品列表 -->
    <div class="list-top">
      <div class="top" v-for="value of sidList" :key="value.title">
        <img :src="value.imgUrl" alt="" />
        <p class="title">{{ value.title }}</p>
        <p class="price">
          <span>{{ value.price }}</span>
          <button>查看详情</button>
        </p>
      </div>
    </div>
    <!-- 纵向排列商品列表 -->
    <div class="list-bottom">
      <div class="bottom" v-for="value of lengthwaysList" :key="value.title">
        <img :src="value.imgUrl" alt="" />
        <div class="right">
          <p class="title">{{ value.title }}</p>
          <p class="price">
            <span>{{ value.price }}</span>
            <button>查看详情</button>
          </p>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
import { onMounted, computed } from "vue";
import { useStore } from "vuex";
export default {
  setup() {
    const store = useStore();
    const getListBottom = () => store.dispatch("getListBottom");
    const getListTop = () => store.dispatch("getListTop");
    onMounted(() => {
      getListBottom();
      getListTop();
    });
    // 横向排列商品列表
    const sidList = computed(() => store.state.loudVoice.getListTop.result);
    // 纵向排列商品列表
    const lengthwaysList = computed(
      () => store.state.loudVoice.getListBottom.result
    );
    return {
      sidList,
      lengthwaysList,
      getListBottom,
      getListTop,
    };
  },
};
</script>

<style lang="less" scoped>
.around-the-mall {
  font-family: PingFang SC;
  font-weight: bold;
  margin-bottom: 22px;
  h1 {
    margin-bottom: 14px;
    color: #333333;
    font-size: 20px;
  }
  // 横向排列商品列表
  .list-top {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .top {
      height: 226px;
      width: 168px;
      margin-bottom: 9px;
      background: #ffffff;
      box-shadow: 0px 0px 13px 0px rgba(234, 234, 234, 0.33);
      border-radius: 8px;
      padding: 0 15px;
      padding-top: 19px;
      display: flex;
      flex-direction: column;
      align-items: center;
      img {
        width: 121px;
        height: 120px;
        margin-bottom: 14px;
      }
      .title {
        margin-bottom: 17px;
        font-size: 15px;
        color: #333333;
      }
      .price {
        display: flex;
        align-items: center;
        justify-content: space-around;
        color: #fa601f;
        font-size: 15px;
        button {
          border: none;
          outline: none;
          width: 69px;
          height: 26px;
          text-align: center;
          line-height: 26px;
          background-color: #fdd208;
          border-radius: 13px;
          font-size: 12px;
          color: #333333;
          margin-left: 27px;
        }
      }
    }
  }
  // 纵向排列商品列表
  .list-bottom {
    display: flex;
    flex-direction: column;
    .bottom {
      background: #ffffff;
      box-shadow: 0px 0px 13px 0px rgba(234, 234, 234, 0.33);
      border-radius: 8px;
      margin-bottom: 9px;
      height: 151px;
      padding-left: 14px;
      padding-right: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      img {
        width: 122px;
        height: 121px;
        margin-right: 14px;
      }
      .right {
        flex: 1;
        height: 121px;
        padding: 4px 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .title {
          color: #333333;
          font-size: 15px;
          line-height: 22px;
        }
        .price {
          color: #fa601f;
          font-size: 15px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          button {
            border: none;
            outline: none;
            background: #fdd208;
            border-radius: 13px;
            font-size: 12px;
            color: #333333;
            text-align: center;
            width: 69px;
            height: 26px;
            line-height: 26px;
          }
        }
      }
    }
  }
}
</style>
